export function getItem(k) {
  const value = window.localStorage.getItem(k)
  try {
    return JSON.parse(value)
  } catch (err) {
    return value
  }
}

export function setItem(k, v) {
  if (v === undefined) {
    window.localStorage.removeItem(k)
    return
  }
  if (typeof v === 'object') {
    v = JSON.stringify(v)
  }
  window.localStorage.setItem(k, v)
}
